<script>
    function accessMenu(link){
        accessLoad("<?= base_url(); ?>index.php?/admin_settings/"+link);
    }

    function accessLoad(url){
        $("#loadingAccess").show();
        $("#accessPage").load(url);
    }

    function submitForm(){
        $("#loadingAccess").show();
        var dataString = 'name='+ $("input#group_name").val() + '&description=' + $("textarea#description").val();
        //        alert (dataString);return false;
        $.ajax({
            type: "POST",
            url: "<?= base_url() ?>index.php?/admin_settings/saveGroup",
            data: dataString,
            success: function() {
                accessMenu("groups");
            }
        });  
    }
    function callUrl(url,prompt){
        if(confirm(prompt)){
            $("#loadingAccess").show();
            $.get(url, function(data){
                accessMenu("groups");
            });
        }
    }

    function changed(id, tab, group, offset){
        var val=$("input:radio[name="+id+"]:checked").val();
        $("#loadingAccess").show();
        $.get("<?= base_url(); ?>index.php?/admin_settings/setAccess/"+group+"/"+tab+"/"+val, function(data){
            accessMenu("groupPermissions/"+group+"/"+offset);
        });
    }

    $('a').click(function() {
        if(this.href.indexOf("admin_settings/groupPermissions", 0)>=0){
            accessLoad(this.href);
            return false;
        }
        return true;
    });

</script>
<div id="accessPage">
    <div class="post">
        <?php foreach ($access_menus as $link => $label) {
        ?>
            <p class="" style="display: inline;text-decoration: underline;padding-right: 5px"><a href="javascript:accessMenu('<?= $link ?>');"><?= $label ?></a></h2>
            <?php } ?>
        <h2 class="title"><?= $title; ?></h2>
        <div class="entry">

            <input type="button" value="Add new" onclick="show('#new_group')"/>
            <img src="<?= base_url(); ?>images/loading.gif" alt="Loading.." style="display: none;" id="loadingAccess"/>
            <div id="admin_result" style="display: none" >
            </div>
            <!--a href="" id="hide3" >Hide</a> <a href="" id="show3" >Show</a-->
            <div id="new_group" style="display: none;margin-bottom: 10px;">
                <?php $data['id'] = "asset_form" ?>
                <?= form_open_multipart('admin_settings/saveGroup', $data); ?>
                <table>
                    <tr class="darker"><td class="half">Name</td><td><input type="text" class="wide" name="group_name"  id="group_name" /></td> </tr>
                    <tr  class="darker"><td>Description</td><td><textarea  class="wide" name="description" id="description" ></textarea> </td> </tr>
                    <tr><td colspan="2" style="text-align: right">
                            <input type="button" value="Submit" onclick="submitForm()" />
                            <input type="button" value="Cancel" onclick="hide('#new_group')" onchange="" />
                        </td></tr>
                </table>
                </form>
            </div>
            <div id="all_asset">
                <?= $pagina ?>
                <?= $tablet ?>
                <?= $pagina ?>
            </div>

        </div>
    </div>
</div>